//
// Created by Max on 2025/5/28.
//

#ifndef ALL_MIC_DETECT_MIC_THREAD_H
#define ALL_MIC_DETECT_MIC_THREAD_H

#include "../common/TvThread.h"
#include "MicConfig.h"
#include "SaveWav.h"

class MicThread : public TvThread,public ITvThreadEvt{

private:
    static MicThread *s_pMicThread;
    static std::mutex s_Mutex;
public:
    MicThread(/* args */);
    ~MicThread();

    int Init(int channelNum,int sampleRate);

    int DeInit();

    bool isMicThreadRunning();

    static MicThread *getInstance();

private:
    void Run(const void *arg) override;

    void OnTvMWThreadExit(TvThread *pTvMWThread) override;

private:
    bool m_bIsMicThreadRunning;
    MicConfig *m_pMtkConfig;
    SaveWav *m_pSaveWav;
    bool isSaveFiles;
    int mTotalFramesRead;
};

#endif //ALL_MIC_DETECT_MIC_THREAD_H
